﻿Imports CQRSAzure.EventSourcing

''' <summary>
''' An interface for any class that decides if an aggregate is in or our of an identity group
''' </summary>
''' <typeparam name="TAggregate">
''' The type of the aggregate identifier which is to be evaluated
''' </typeparam>
Public Interface IClassifier(Of TAggregate As IAggregationIdentifier)

    ''' <summary>
    ''' Perform the classifier to evaluate if the given aggregate identifier 
    ''' </summary>
    ''' <param name="aggregateInstance">
    ''' The unique instance of the aggregate to evaluate
    ''' </param>
    ''' <returns>
    ''' True if the classifier considers the aggregate to be a member of the group, otherwise false
    ''' </returns>
    Function IsInGroup(ByVal aggregateInstance As TAggregate) As Boolean

    ''' <summary>
    ''' Perform the classifier to evaluate if the given aggregate identifier 
    ''' </summary>
    ''' <param name="aggregateInstance">
    ''' The unique instance of the aggregate to evaluate
    ''' </param>
    ''' <param name="AsOf">
    ''' The effective date that we are evaluating the membership for (we run the event stream up until that point)
    ''' </param>
    ''' <returns>
    ''' True if the classifier considers the aggregate to be a member of the group, otherwise false
    ''' </returns>
    Function IsInGroup(ByVal aggregateInstance As TAggregate, ByVal AsOf As DateTime) As Boolean

End Interface

''' <summary>
''' An interface for a class that handles a specific event to decide if an aggregate is in or out of an identity group
''' </summary>
''' <typeparam name="TEvent">
''' The specific event being evaluated
''' </typeparam>
Public Interface IClassifierEventHandler(Of TEvent As IEvent)

    ''' <summary>
    ''' The evaluation result of evaluating this given event
    ''' </summary>
    Enum EvaluationResult
        ''' <summary>
        ''' The in/out analysis is not changed by the evaluation of this event
        ''' </summary>
        Unchanged = 0
        ''' <summary>
        ''' The in/out analysis is set to include this item in the group
        ''' </summary>
        Include = 1
        ''' <summary>
        ''' The in/out analysis is set to exclude this item according to this event
        ''' </summary>
        Exclude = 2
    End Enum

    Function Evaluate(ByVal eventToEvaluate As TEvent) As EvaluationResult

End Interface